import axios from 'axios'
import qs from 'qs'
//设置默认地址
axios.defaults.baseURL = "http://127.0.0.1:5000/"


//分装的axios
const myaxios = function(url, method, data = {}) {
    return new Promise((resolve) => {
        if (method == 'get' || method == 'delete') {
            axios({ 'url': url, 'method': method, 'params': qs.stringify(data) }).then(res => {
                return resolve(res.data)
            })
        } else {
            axios({ 'url': url, 'method': method, 'data': qs.stringify(data) }).then(res => {
                return resolve(res.data)
            })
        }
    })
}
export default myaxios;